# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI="1"
RESTRICT="mirror test"

inherit eutils rpm versionator

MY_PV=$(replace_version_separator 2 '-')
MY_P=${PN}-${MY_PV}

DESCRIPTION="Simply Accounting 2010 Connection Manager for Linux"
HOMEPAGE="http://www.simplyaccounting.com/supportTraining/install/"
SRC_URI="http://simplydownload.accpac.com/downloads/simplyaccounting/install/2010/${MY_P}.i386.rpm"

LICENSE="SAGE_SA_License_Ref"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE=""

DEPEND=""
RDEPEND="net-fs/samba
	=dev-db/myodbc-3.51*
	>=dev-lang/mono-2.0"


S="${WORKDIR}"

pkg_setup() {
	enewgroup simplyconnmgr
	enewuser simplyconnmgr -1 -1 -1 "simplyconnmgr"
}

src_unpack() {
	rpm_src_unpack ${A}
	cd "${S}"
}

src_install() {
	dodir /usr/local || die
	cp -dpR "${S}/usr/local/bin" "${D}/usr/local" || die "cp failed on SageSAConnMgr binaries"
	cp -dpR "${S}/usr/local/etc" "${D}/usr/local" || die "cp failed on SageSAConnMgr config files"
	dodir /etc || die
	dosym "../usr/local/etc/Sage Software/ConnectionManager" /etc/sagesaconnmgr || die
	newinitd "${FILESDIR}/${PN}.initd" "${PN}" || die
	newconfd "${FILESDIR}/${PN}.confd" "${PN}" || die
	elog "========================================================"
	elog "Simply Accounting Connection Manager for Linux"
	elog ""
	elog "Copyright (c) 2009 Sage Software, Inc."
	elog "All rights reserved."
	elog ""
	elog "This package is subject to the Sage License Agreement"
	elog "enclosed in the Simply Accounting 2010 software package."
	elog ""
	elog "The Connection Manager for Linux is available"
	elog "free-of-charge to all customers running Simply"
	elog "Accounting 2010."
	elog "========================================================"
	elog ""
	elog "For more information please take a look at the README file, available at:"
	elog "http://simplydownload.accpac.com/downloads/simplyaccounting/install/2010/LinuxConnectionManager_Readme.txt"
}
